package com.codingbetter.jpa.controller;

import com.codingbetter.jpa.model.Book;
import com.codingbetter.jpa.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Tony Zhang
 **/
@RestController
@RequestMapping("/books")
public class BookController {
    @Autowired
    private BookRepository bookRepository;

    @GetMapping
    public String index() {
        return "202310311622";
    }

    @PostMapping
    public Book create(@RequestBody Book book) {
        this.bookRepository.save(book);
        return book;
    }
}
